package com.example.community.entity;

import com.alibaba.fastjson.JSON;
//import com.baomidou.mybatisplus.annotation.IdType;
//import com.baomidou.mybatisplus.annotation.TableField;
//import com.baomidou.mybatisplus.annotation.TableId;
//import com.baomidou.mybatisplus.annotation.TableName;
//import com.starp.exam.domain.enums.QuestionTypeEnum;
//import com.starp.exam.domain.question.QuestionItemObject;
//import com.starp.exam.utility.ExamUtil;
//import io.swagger.annotations.ApiModel;
//import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

//import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

//@Entity
@Builder
@AllArgsConstructor
@Data
//@Table
//@Table(name = "t_question")
//: Table 'lamperouge.question' doesn't exist
//@ApiModel
//@TableName("t_question")
@Document(indexName = "question",
        shards = 4, replicas = 2)      // es搜索引擎
public class Question implements Serializable {
//public  static  class Names{
//    public  static String  id="id";
//}

    public  static  class Names{
//        public  static String  id="id";
        public  static String  correct="correct";
        public  static String  create_time="create_time";
        public  static String  create_user="create_user";
        public  static String  deleted="deleted";
        public  static String  difficult="difficult";
        public  static String  grade_level="grade_level";
        public  static String  info_text_content_id="info_text_content_id";
        public  static String  question_type="question_type";
        public  static String  score="score";
        public  static String  status="status";
        public  static String  subject_id="subject_id";

        public  static String  id="id";
        public  static String  quesContent="quesContent";
        public  static String  questionType="questionType";
        public  static String  subjectId="subjectId";
//        public  static String  score="score";
        public  static String  gradeLevel="gradeLevel";
//        public  static String  difficult="difficult";
//        public  static String  correct="correct";
        public  static String  infoTextContentId="infoTextContentId";
        public  static String  createUser="createUser";
        public  static String  videoLink="videoLink";
//        public  static String  status="status";
//        public  static String  deleted="deleted";
        public  static String  analyze="analyze";
        public  static String  title="title";
    }
//es 自增 的id
    @Id
//    @ApiModelProperty("id")
//    @TableId(type = IdType.AUTO)
//    @Field(type = FieldType.Integer)
//    @Field(type = FieldType.Integer)
//    @GeneratedValue(strategy = GenerationType.IDENTITY)
//    private Integer id;
    private String id;
//    static String  id="id";

//    @Transient
//    @TableField(exist = false)
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    String quesContent;
//    @Transient
//    String items;

    /**
     * 1.单选题 2.多选题 3.判断题 4.填空题 5.简答题
     */
    private Integer questionType;

    /**
     * 学科
     */
    private Integer subjectId;

    /**
     * 题目总分(千分制)
     */
    private Integer score;

    /**
     * 级别
     */
    private Integer gradeLevel;

    /**
     * 题目难度
     */
    private Integer difficult;


    /**
     * 正确答案
     */
    private String correct;

    /**
     * 题目 填空、 题干、解析、答案等信息
     */
    private Integer infoTextContentId;

    /**
     * 创建人
     */
    private Integer createUser;
    String videoLink;
    /**
     * 1.正常
     */
    private Integer status;

    /**
     * 创建时间
     */
    private Date createTime;

    private Boolean deleted;

//    @Transient
//    @TableField(exist = false)
    String analyze;
//
//    @Transient
//    @TableField(exist = false)
    String title;

//    @Transient
//    @TableField(exist = false)
//    List<QuestionItemObject> items;


    private static final long serialVersionUID = 8826266720383164363L;

    public String getVideoLink() {
        return videoLink;
    }

    public void setVideoLink(String videoLink) {
        this.videoLink = videoLink;
    }

    public static class Status {
        public static Integer normal = 1;
    }

    public static class QuestionType {
        //        1.单选题 2.multipleChoice 3.trueOrFalse 4.填空题 5.简答题
//        单选题
//   Single choice question
        Integer SingleChoice = 1;
        Integer multipleChoice = 1;
        Integer trueOrFalse = 1;
    }

//    public Integer getId() {
//        return id;
//    }
//
//    public void setId(Integer id) {
//        this.id = id;
//    }

    public Integer getQuestionType() {
        return questionType;
    }

    public void setQuestionType(Integer questionType) {
        this.questionType = questionType;
    }

    public Integer getSubjectId() {
        return subjectId;
    }

    public void setSubjectId(Integer subjectId) {
        this.subjectId = subjectId;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer score) {
        this.score = score;
    }

    public Integer getGradeLevel() {
        return gradeLevel;
    }

    public void setGradeLevel(Integer gradeLevel) {
        this.gradeLevel = gradeLevel;
    }

    public Integer getDifficult() {
        return difficult;
    }

    public void setDifficult(Integer difficult) {
        this.difficult = difficult;
    }

    public String getCorrect() {
        if (correct == null) {
            correct = "";
        }
        return correct;
    }

    public void setCorrect(String correct) {
        this.correct = correct == null ? null : correct.trim();
    }

    public Integer getInfoTextContentId() {
        return infoTextContentId;
    }

    public void setInfoTextContentId(Integer infoTextContentId) {
        this.infoTextContentId = infoTextContentId;
    }

    public Integer getCreateUser() {
        return createUser;
    }

    public void setCreateUser(Integer createUser) {
        this.createUser = createUser;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }


//    public void setCorrectFromVM(String correct, List<String> correctArray) {
//        int qType = this.getQuestionType();
//        if (qType == QuestionTypeEnum.MultipleChoice.getCode()) {
//            String correctJoin = ExamUtil.contentToString(correctArray);
//            this.setCorrect(correctJoin);
//        } else {
//            this.setCorrect(correct);
//        }
//    }

    public static int notDeleted = 0;

    public Question() {
    }

    public static void main(String[] args) {
        final Question question = new Question();
        String s = JSON.toJSONString(question);
//        获取 java 实体的所有字段
        System.out.println(s);
    }

}
